


<!DOCTYPE html>
<html id="htmlId">
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
  <title>Coverage Report > MainActivity</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">com.example.robolectricsample</a>
</div>

<h1>Coverage Summary for Class: MainActivity (com.example.robolectricsample)</h1>

<table class="coverageStats">

<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Branch, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">MainActivity</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (9/9)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    50%
  </span>
  <span class="absValue">
    (1/2)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (22/22)
  </span>
</td>
</tr>
  <tr>
    <td class="name">MainActivity$dataObverse$1</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
  </tr>
  <tr>
    <td class="name">MainActivity$sam$androidx_lifecycle_Observer$0</td>
  </tr>
<tr>
  <td class="name"><strong>Total</strong></td>
<td class="coverageStat">
  <span class="percent">
    90%
  </span>
  <span class="absValue">
    (9/10)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    50%
  </span>
  <span class="absValue">
    (1/2)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    95.7%
  </span>
  <span class="absValue">
    (22/23)
  </span>
</td>
</tr>
</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package com.example.robolectricsample
&nbsp;
&nbsp;import android.content.Intent
&nbsp;import android.os.Bundle
&nbsp;import android.util.Log
&nbsp;import android.widget.Button
&nbsp;import android.widget.TextView
&nbsp;import android.widget.Toast
&nbsp;import androidx.appcompat.app.AppCompatActivity
&nbsp;import androidx.lifecycle.ViewModelProvider
&nbsp;import androidx.lifecycle.lifecycleScope
&nbsp;import kotlinx.coroutines.launch
&nbsp;
<b class="fc">&nbsp;class MainActivity : AppCompatActivity() {</b>
&nbsp;
<b class="fc">&nbsp;    lateinit var viewModel: MainViewModel</b>
&nbsp;
&nbsp;    override fun onCreate(savedInstanceState: Bundle?) {
<b class="fc">&nbsp;        super.onCreate(savedInstanceState)</b>
<b class="fc">&nbsp;        setContentView(R.layout.layout_main)</b>
<b class="fc">&nbsp;        Log.d(&quot;GJ&quot;, &quot;onCreate ----&quot;)</b>
&nbsp;
<b class="fc">&nbsp;        val button: Button = findViewById(R.id.btn_test)</b>
&nbsp;
<b class="fc">&nbsp;        button.setOnClickListener {</b>
<b class="fc">&nbsp;            onButtonTestClick()</b>
&nbsp;        }
&nbsp;
<b class="fc">&nbsp;        viewModel = ViewModelProvider(this)[MainViewModel::class.java]</b>
&nbsp;
<b class="fc">&nbsp;        dataObverse()</b>
<b class="fc">&nbsp;        loadData()</b>
&nbsp;    }
&nbsp;
<b class="fc">&nbsp;    private val condition: Int = 1</b>
&nbsp;
&nbsp;    fun loadData() {
<b class="pc">&nbsp;        if (condition == 1) {</b>
<b class="fc">&nbsp;            viewModel.fetchList()</b>
&nbsp;        } else {
&nbsp;
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;    fun onButtonTestClick() {
<b class="fc">&nbsp;        Toast.makeText(this, getString(R.string.toast_text), Toast.LENGTH_SHORT).show()</b>
<b class="fc">&nbsp;        val intent = Intent(this, SecondActivity::class.java)</b>
<b class="fc">&nbsp;        startActivity(intent)</b>
&nbsp;    }
&nbsp;
&nbsp;    override fun onResume() {
<b class="fc">&nbsp;        super.onResume()</b>
<b class="fc">&nbsp;        Log.d(&quot;GJ&quot;, &quot;onResume ----&quot;)</b>
&nbsp;    }
&nbsp;
&nbsp;    override fun onPause() {
<b class="fc">&nbsp;        super.onPause()</b>
<b class="fc">&nbsp;        Log.d(&quot;GJ&quot;, &quot;onPause ----&quot;)</b>
&nbsp;    }
&nbsp;
&nbsp;    fun dataObverse() {
<b class="fc">&nbsp;        viewModel.mainStringData.observeForever {</b>
<b class="nc">&nbsp;            findViewById&lt;TextView&gt;(R.id.txt_value).setText(it)</b>
&nbsp;        }
&nbsp;    }
&nbsp;
&nbsp;}
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2024-10-13 16:00</div>
</div>
</body>
</html>
